<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h3>双向数据绑定</h3>

    <script>
        let obj = {}
        let temp = "赵六"
        // let obj = {
        //     name: "张三"
        // }
        // 数据劫持
        // Object.defineProperty(初始数据, key, option)
        Object.defineProperty(obj, 'name', {
            // 
            // value: '王五'
            // get函数  读取里面的值就会执行
            get() {
                console.log('get函数执行')
                return temp
            },
            set(val) {
                temp = val
                console.log('set函数执行', val)
            }
        })
        obj.name = '冯七'

    </script>
</body>
</html>